#include "algo.h"
#include "ui_algo.h"


Algorithm::Algorithm(QString Who, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Algorithm)
{
    ui->setupUi(this);
    WhoAmI = Who;
    WhereFins = new Fins;
    InitSettings = new QSettings("Init2.ini",QSettings::IniFormat);
    InitSettings->setIniCodec( "utf8" );
    QString PropName = WhoAmI + "/Name";
    QString Name = InitSettings->value((PropName)).toString();

    QPushButton *buttonSelectF = new QPushButton(tr(Name.toAscii()));
    PropName = WhoAmI + "/FirstLabel";
    Name = InitSettings->value((PropName)).toString();
    QLabel *labelTemp = new QLabel(Name);

    PropName = WhoAmI + "/SecondLabel";
    Name = InitSettings->value((PropName)).toString();
    QLabel *labelPower = new QLabel(Name);
    CycleOnOff = new OmronFloat(WhoAmI, "CycleOnOff", this);
    AllCicle = new OmronFloat(WhoAmI, "AllCicle", this);
    PullUp = new OmronFloat(WhoAmI, "PullUp", this);
    BaseLevel = new OmronFloat(WhoAmI, "BaseLevel", this);
    FeedMode = new OmronFloat(WhoAmI, "FeedMode", this);
    FeedPeriod = new OmronFloat(WhoAmI, "FeedPeriod", this);
    FeedTune = new OmronInt(WhoAmI, "FeedTune", this);

    QVBoxLayout *VBox =  new QVBoxLayout;
    VBox->addWidget(buttonSelectF);
    VBox->addWidget(labelTemp);
    VBox->addWidget(CycleOnOff);
    VBox->addWidget(AllCicle);
    VBox->addWidget(PullUp);
    VBox->addWidget(BaseLevel);
    VBox->addWidget(labelPower);
    VBox->addWidget(FeedMode);
    VBox->addWidget(FeedPeriod);
    VBox->addWidget(FeedTune);
    setLayout(VBox);
}

Algorithm::~Algorithm()
{
    delete ui;
}

void Algorithm::SetWhereFins(Fins *addr)
{
    this->WhereFins = addr;
    CycleOnOff->SetWhereFins(WhereFins);
    AllCicle->SetWhereFins(WhereFins);
    PullUp->SetWhereFins(WhereFins);
    BaseLevel->SetWhereFins(WhereFins);
    FeedMode->SetWhereFins(WhereFins);
    FeedPeriod->SetWhereFins(WhereFins);
    FeedTune->SetWhereFins(WhereFins);
}

void Algorithm::nextField (const QString & WhoSend)
{
    qDebug()<<"Algorithm nextField"<<WhoSend;
}
void Algorithm::prevField (const QString & WhoSend)
{
    qDebug()<<"Algorithm prevField"<<WhoSend;
}


